use repeated_cross_section, clear

// muslim indicator
gen muslim=(paiperc=="06"|paiperc=="08")

// Matching variables
// Individual
encode tau10, gen(urbanst)

destring zus, replace

ebalance muslim i.ag i.urbanst i.zus if pnai28=="10" & female==1, tar(1) keep("TableB2") generate(ebal_weight)

// interaction
gen inter=muslim*treatedcoh

// linear trend
tab birthyear, gen(coh)
sum birthyear
local minyear=r(min)
local maxyear=r(max)-r(min)
gen t=birthyear-`minyear'+1
gen tmuslim=t*muslim

// father birthplace FE
egen pbpl=group(paiperc)

estimates clear
local sample if pnai28=="10" & female==1 [pweight=ebal_weight]
local cl pbpl
estimates clear
reghdfe secondary inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear)
eststo m1

reghdfe secondary inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.surveyr)
eststo m2

reghdfe secondary inter `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.ag##i.pbpl i.surveyr)
eststo m3

reghdfe secondary inter tmuslim `sample', cluster(`cl') absorb(i.pbpl i.birthyear i.ag##i.pbpl i.surveyr)
eststo m4

esttab m* using "TableB3.csv", star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace ///
		cells(b(fmt(a3) star) se(par)) stats(N r2)  ///
		keep(inter*) 
